package com.jieyun.rbac.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jieyun.core.component.page.Pager;
import com.jieyun.core.utils.ServerResponse;
import com.jieyun.rbac.dto.SysUserDTO;
import com.jieyun.rbac.param.SysUserParam;
import com.jieyun.rbac.query.SysUserQuery;
import com.jieyun.rbac.service.SysUserService;

/**
 * 系统用户controller
 * @author trekxu
 *
 */
@Controller
@RequestMapping("/sys/user")
public class SysUserController {
	
	@Resource
	private SysUserService sysUserService;
	
	
	@RequestMapping("/index")
	public String index() {
		return "sys/user";
	}
	
	/**
	 * 用户添加
	 * @return
	 */
	@RequestMapping("/add")
	@ResponseBody
	public ServerResponse userAdd( SysUserParam user) {
		return this.sysUserService.userAdd(user);
	}
	
	/**
	 * 用户删除
	 * @param id
	 * @return
	 */
	@RequestMapping("/delete")
	@ResponseBody
	public ServerResponse userDelete(Integer id) {
		return this.sysUserService.userDelete(id);
	}
	
	
	/**
	 * 系统用户信息更新
	 * @param user
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/update")
	public ServerResponse userUpdate(SysUserParam user) {
		return this.sysUserService.updateUser(user);
	}
	
	/**
	 * 激活或者冻结
	 * @param id
	 * @return
	 */
	@RequestMapping("onOrOff")
	@ResponseBody
	public ServerResponse onOrOff(Integer id) {
		return this.sysUserService.onOrOff(id);
	}
	
	/**
	 * 获取用户分页信息
	 * @return
	 */
	@RequestMapping("/list")
	@ResponseBody
	public Pager<SysUserDTO> userList(SysUserQuery userQuery) {
		return this.sysUserService.userList(userQuery);
	}
}
